<?php

class Template 
{
	private $template;
	
	function __construct($title, $html)
	{
		$this->template = str_replace('{TITLE}', $title, file_get_contents('template/html/' . $html));
	}
	
	public function setContent($section, $content)
	{
		$this->template = str_replace($section, $content, $this->template);
	}
	
	public function getContent($template, $content)
	{
		global $templateObjects;
		
		$structure = @file_get_contents($template . '.html');
		if(!$structure) 
		{ 
			return 'Error: Invalid template id (' . $template .')';			
		}
		
		return str_replace($templateObjects[$template], $content, $structure);
	}
	
	public function display()
	{
		echo $this->template;
		return true;
	}
}